﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Inventory_AuditingOrder : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["OrderID"]))
        {
            if (!this.IsPostBack)
            {
                Order order = Inventory.getOrder(Request["OrderID"]);
                this.lblOrderId.Text = order.OrderID;
                this.lblStoreName.Text = order.StoreName;
                this.TextBox1.Text = order.AuditingDescription;
                this.lblStoreID.Text = order.StoreID;
                this.lblOrderDate.Text = order.OrderDate.ToString("yyyy-MM-dd");
                this.lblRush.Text = order.IsRush ? "是" : "否";
                this.lblDeliveryDate.Text = order.ArriveDate.ToString("yyyy-MM-dd");
                this.lblOrderName.Text = order.OrderName;
                if (order.IsAccept.HasValue)
                {
                    this.btnAccept.Enabled = false;
                    this.btnReject.Enabled = false;
                }
            }

        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Inventory/OrderList.aspx");
    }
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(this.lblOrderId.Text.Trim()))
        {
            if (Inventory.AuditingOrder(this.lblStoreID.Text ,this.lblOrderId.Text.Trim(), true, TextBox1.Text))
            {
                lblMessage.Text = "订单处理成功";
                this.btnAccept.Enabled = false;
                this.btnReject.Enabled = false;
            }
            else
                lblMessage.Text = "订单处理失败";
        }
    }
    protected void btnReject_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(this.lblOrderId.Text.Trim()))
        {
            if (Inventory.AuditingOrder(this.lblStoreID.Text ,this.lblOrderId.Text.Trim(), false, TextBox1.Text))
            {
                lblMessage.Text = "订单处理成功";
                this.btnAccept.Enabled = false;
                this.btnReject.Enabled = false;
            }
            else
                lblMessage.Text = "订单处理失败";
        }
    }
}
